import SendGQL from "@/api/SendGQL";

const ListMonk = `
  query ListMonk ($perPage: Int64!, $page: Int64!) {
    listMonk ( perPage: $perPage, page: $page) {
      count
      list {
        address,
        createTime,
        gender,
        id,
        img,
        name,
        nation,
        number,
        post,
        temple
      }
    }
  }
`;

export const listMonk = (params) => {
  const { perPage, page } = params;
  return SendGQL({
    query: ListMonk,
    variables: {
      perPage,
      page,
    },
  });
};

const GetMonk = `
  query Monk ($id: String) {
    monk (id: $id) {
      address
      createTime
      gender
      id
      img
      name
      nation
      number
      post
      remarks {
        belong {
          certificate
          degree
          disciplined
          disciplinedtime
          dratsang
          identity
          post
          religious
          responsibility
          sects
          shrine
          teacher
          telephone
          templeposition
          templetime
        }
        crime
        exit {
          backflowmode
          backflowtime
          exitmode
          exittime
        }
        performance
        personal {
          address
          birth
          education
          gender
          idnumber
          legalname
          name
          nation
          native
          postcode
          registered
          usedname
        }
        resume
        social {
          Appellations
          Name
          Occupation
        }
        train
      }
      temple
    }
  }
`;

export const getMonk = (id) => {
  return SendGQL({
    query: GetMonk,
    variables: {
      id,
    },
  });
};

const CreateMonk = `
  mutation CreateMonk{
    createMonk($monk: monkInPut, $id: String)
  }
`;
/**
 *
 * @param {*} params
 * params = { monk: {
 *  personal: ''
    belong: ''
    exit: ''
    train: ''
    resume: ''
    social: ''
    performance: ''
    crime: ''
 * }, id: ''}
 * @returns
 */

export const createMonk = (params) => {
  const { monk, id } = params;
  return SendGQL({
    query: CreateMonk,
    variables: {
      monk,
      id,
    },
  });
};

const UpdateMonk = `
  mutation UpdateMonk{
    updateMonk($monk: monkInPut, $id: String)
  }
`;
/**
 *
 * @param {*} params
 * params = { monk: {
 *  personal: ''
    belong: ''
    exit: ''
    train: ''
    resume: ''
    social: ''
    performance: ''
    crime: ''
 * }, id: ''}
 * @returns
 */

export const updateMonk = (params) => {
  const { monk, id } = params;
  return SendGQL({
    query: UpdateMonk,
    variables: {
      monk,
      id,
    },
  });
};

const ListTemple = `
  query ListTemple ($perPage: Int64!, $page: Int64!) {
    listTemple (perPage: $perPage, page: $page) {
      count
      list{
        createTime
        department
        id
        name
        remarks
        sects
        templeimg
        township
      }
    }
  }
`;

export const listTemple = (params) => {
  const { name, perPage, page } = params;
  return SendGQL({
    query: ListTemple,
    variables: {
      name,
      perPage,
      page,
    },
  });
};
